package cn.yunbamboos.mybatis.mapping.methods.custom;

import cn.yunbamboos.mybatis.mapping.methods.BaseMethod;
import cn.yunbamboos.mybatis.metadata.TableInfo;
import org.apache.ibatis.mapping.SqlCommandType;
import org.apache.ibatis.mapping.SqlSource;
import org.apache.ibatis.scripting.defaults.RawSqlSource;
import org.apache.ibatis.session.Configuration;

public class CustomUpdateMethod extends BaseMethod {

    private String sql;

    public CustomUpdateMethod(String methodName, Configuration configuration, TableInfo tableInfo) {
        super(methodName, configuration, tableInfo, SqlCommandType.UPDATE);
    }

    @Override
    protected SqlSource getSqlSource() {
        return new RawSqlSource(configuration, this.sql, this.tableInfo.getEntityType());
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

}